#include "DoubleSquarePulse.h"

#include <cmath>

DoubleSquarePulse::DoubleSquarePulse()
{

}

DoubleSquarePulse::~DoubleSquarePulse()
{

}
void DoubleSquarePulse::Current(NewParameters params)
{
  //Parameters *p=Parameters::getInstance();
  firstLength=params.getDoublePulse()["firstLength"];
  secondLength=params.getDoublePulse()["secondLength"];
  length=firstLength+secondLength;
  firstLevel=params.getDoublePulse()["firstAmplitude"];  
  secondLevel=params.getDoublePulse()["secondAmplitude"];
  delay=params.getDoublePulse()["delay"]; 
}

void DoubleSquarePulse::Field(NewParameters params)
{
  /*//Parameters *p=Parameters::getInstance();
  length=p->getDouble("fieldPulseLength");
  level=p->getDouble("field");
  angle=p->getDouble("angleField");
  angle2=p->getDouble("angleField2");*/
}

double DoubleSquarePulse::getLevel(double timestamp)
{
  if(timestamp<=firstLength)
    return firstLevel;
  if(timestamp>firstLength && timestamp<=(firstLength+delay))
    return 0;
  if(timestamp>(firstLength+delay) && timestamp<=(firstLength+delay+secondLength))
    return secondLevel;
  else return 0;
}

double DoubleSquarePulse::getSecondPulse()
{
  return secondLength;
}

void DoubleSquarePulse::setSecondPulse(double value)
{
  secondLength=value;
}
